package com;
import java.util.concurrent.ThreadFactory;
class YootkThreadFactory implements ThreadFactory{
//定义线程工厂实现类
    private static final ThreadFactory INSTANCE=new YootkThreadFactory();
    private static final String TITLE="yootk-";//定义线程标记名称
    private static int count=0;//线程个数统计
    private YootkThreadFactory(){}//构造函数私有化
    public static ThreadFactory getInstance(){//获取本类实例
    return INSTANCE;}
    @Override
    public Thread newThread(Runnable run){
    return new Thread(run,TITLE + count++);}
}//获取线程实例
public class h3{
    public static void main(String[]args) throws Exception {
        Thread thread = YootkThreadFactory.getInstance().newThread(()->{//获取线程对象
        System.out.println("多线程执行，" + Thread.currentThread().getName());
    });
            thread.start();}
}
